#!/bin/bash
if [ ! -f privatekey.txt ];then
openssl genrsa -out rsa_private_key.pem 1024
openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt > privatekey.txt
openssl rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
cat rsa_public_key.pem | grep -v "BEGIN PUBLIC KEY" | grep -v "END PUBLIC KEY"
else
echo "已存在 privatekey.txt"
fi

